package com.ruoyi.web.service.caochongService.caochongServiceimpl;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.web.domain.Comment;
import com.ruoyi.web.domain.ScenicSpot;
import com.ruoyi.web.mapper.ScenicSpotMapper;
import com.ruoyi.web.service.caochongService.CommentService;
import com.ruoyi.web.service.caochongService.ScenicSpotService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author fancheng
 * @since 2022-11-05
 */
@Service
public class ScenicSpotServiceImpl extends ServiceImpl<ScenicSpotMapper, ScenicSpot> implements ScenicSpotService {
   @Autowired
    private CommentService commentService;


    @Override
    public ScenicSpot findScenicById(Integer id) {
        ScenicSpot scenicSpot = lambdaQuery().eq(ScenicSpot::getId,id).one();
        List<Comment> list = commentService.lambdaQuery().eq(Comment::getScenicId, scenicSpot.getId()).list();
        scenicSpot.getData().put("commentList",list);
        return scenicSpot;
    }
}
